package com.one.common.common.order.binder;

import android.annotation.SuppressLint;
import android.support.annotation.NonNull;
import android.view.View;

import com.one.common.R;
import com.one.common.common.order.AddMaterialItem;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;

/**
 * creator: zhulunjun
 * time:    2018/8/9
 * describe: 收费，免费项
 */
public class MaterialInfoBinder extends BaseItemBinder<AddMaterialItem> {
    public MaterialInfoBinder() {
        super(R.layout.item_material_info);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull AddMaterialItem item) {
        if (item.getTotalPrice() > 0) {
            if(item.getType()==0){
                holder.getView(R.id.tv_name).setVisibility(View.INVISIBLE);
                holder.getView(R.id.tv_price).setVisibility(View.INVISIBLE);
            }else if(item.getType()==2){
                holder.setText(R.id.tv_name, "应付金额");
                holder.setTextColor(R.id.tv_name, R.color.black);
                holder.setText(R.id.tv_price, "￥"+item.getTotalPrice()+"");
            }else if(item.getType()==1){
                holder.setText(R.id.tv_name, "优惠立减");
                holder.setTextColor(R.id.tv_name, R.color.black);
                holder.setText(R.id.tv_price, "￥"+item.getTotalPrice()+"");
            }

        } else {
            holder.getView(R.id.tv_name).setVisibility(View.VISIBLE);
            holder.setText(R.id.tv_name, item.getName());
            holder.setText(R.id.tv_price, "￥" + item.getPrice() * item.getNum());
        }

    }
}
